﻿
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Webdiyer.WebControls.Mvc;
using XQ.SP.BllServices;
using XQ.SP.Model;
using XM.Comm;
using XM.PermissionFilter;

namespace XiaoQu.Controllers
{
    /// <summary>
    /// 用户
    /// </summary>
    [Description("用户")]
    public class UsersController : Controller
    {
        XQ.SP.BllServices.UsersBLL bllBase = new XQ.SP.BllServices.UsersBLL();

        #region 后台管理
        #region 列表
        [Description("列表")]
        [PermissionFilter]
        public ActionResult List(int pageIndex = 1)
        {
            string valueStr = Request.Form["search_input"];
            string search_type = Request.Form["search_type"];
            List<SelectListItem> ListSeach = new List<SelectListItem>();
            ListSeach.Add(new SelectListItem { Value = "username", Text = "用户名" });
            ListSeach.Add(new SelectListItem { Value = "no", Text = "编号" });
            ListSeach.Add(new SelectListItem { Value = "email", Text = "邮箱" });
            ListSeach.Add(new SelectListItem { Value = "idcard", Text = "身份证" });
            ListSeach.Add(new SelectListItem { Value = "mobil", Text = "手机号码" });
            ListSeach.Add(new SelectListItem { Value = "realname", Text = "真实名字" });
            ListSeach.Add(new SelectListItem { Value = "userpassword", Text = "密码" });
            ListSeach.Add(new SelectListItem { Value = "telephone", Text = "电话号码" });
            ListSeach.Add(new SelectListItem { Value = "qq", Text = "QQ" });
            ListSeach.Add(new SelectListItem { Value = "sex", Text = "性别" });
            ListSeach.Add(new SelectListItem { Value = "address", Text = "地址" });
            ListSeach.Add(new SelectListItem { Value = "description", Text = "个性描述" });
            ListSeach.Add(new SelectListItem { Value = "degree", Text = "等级" });
            ListSeach.Add(new SelectListItem { Value = "weixin", Text = "微信" });
            ListSeach.Add(new SelectListItem { Value = "stuno", Text = "学号" });
            ListSeach.Add(new SelectListItem { Value = "classname", Text = "名称" });
            ListSeach.Add(new SelectListItem { Value = "roles", Text = "角色" });
            ListSeach.Add(new SelectListItem { Value = "depaname", Text = "部门名称" });
            ListSeach.Add(new SelectListItem { Value = "imagesblog", Text = "背景图片" });
            ListSeach.Add(new SelectListItem { Value = "sysdegreename", Text = "等级值" });
            ViewBag.ListSeachType = ListSeach;
            @ViewBag.pageIndex=pageIndex;
            @ViewBag.ListSeachValue=valueStr;

            #region
            int pageSize = 20; 
            XQ.Model.Pager.Pager modelP = new XQ.Model.Pager.Pager();
            modelP.tableName = " Users ";
            modelP.fldName = " * ";
            modelP.pageSize = 20;
            modelP.page = pageIndex;
            modelP.fldSort = " Id ";
            modelP.sort = 1;
            modelP.id = " Id ";
            modelP.dist = 1;
            if (!string.IsNullOrEmpty(valueStr))
            {
                modelP.strCondition += " and "+search_type+" like '%" + valueStr + "%' ";
            }
            modelP = DBUtility.DbHelperSQL.GetPage(modelP);
            #endregion
            List<XQ.SP.Model.UsersItem> list = bllBase.DataTableToList(modelP.dt);
            return View(new PagedList<XQ.SP.Model.UsersItem>(list, pageIndex, pageSize, modelP.counts));
        }
        #endregion

        #region 编辑
        [Description("编辑")]
        [PermissionFilter]
        public ActionResult Edit(long id = 0,int tid=0)
        {
            UsersItem item = new UsersItem();
            item.Status = tid;
            if (id != 0)
            {
                item = bllBase.GetModel(id);
            }

            
            
            //List<SelectListItem> ListAttest = new List<SelectListItem>();
            //ListAttest.Add(new SelectListItem { Value = "邮箱", Text = "邮箱" });
            //ListAttest.Add(new SelectListItem { Value = "手机", Text = "手机" });
            //ViewBag.ListAttest=ListAttest;
            List<SelectListItem> ListUserType = new List<SelectListItem>();
            ListUserType.Add(new SelectListItem { Value = "普通用户", Text = "普通用户" });
            ListUserType.Add(new SelectListItem { Value = "代理用户", Text = "代理用户" });
            ViewBag.ListUserType = ListUserType;
            //List<SelectListItem> ListSysDegreeId = new List<SelectListItem>();
            //XQ.SP.BllServices.SysDegreeBLL bllSysDegree = new XQ.SP.BllServices.SysDegreeBLL();
            //foreach (var mT in  bllSysDegree.GetModelList())
            //{
            //    ListSysDegreeId.Add(new SelectListItem { Value = mT.Id.ToString(), Text = mT.Name.ToString() });
            //}
            //ViewBag.ListSysDegreeId=ListSysDegreeId;

            
            return View(item);
        }

        [Description("编辑")]
        [PermissionFilter]
        [HttpPost]
        [ValidateInput(false)]
        public ActionResult Edit(UsersItem model)
        {
            //List<SelectListItem> ListAttest = new List<SelectListItem>();
            //ListAttest.Add(new SelectListItem { Value = "邮箱", Text = "邮箱" });
            //ListAttest.Add(new SelectListItem { Value = "手机", Text = "手机" });
            //ViewBag.ListAttest = ListAttest;
            List<SelectListItem> ListUserType = new List<SelectListItem>();
            ListUserType.Add(new SelectListItem { Value = "普通用户", Text = "普通用户" });
            ListUserType.Add(new SelectListItem { Value = "代理用户", Text = "代理用户" });
            ViewBag.ListUserType = ListUserType;
            //List<SelectListItem> ListSysDegreeId = new List<SelectListItem>();
            //XQ.SP.BllServices.SysDegreeBLL bllSysDegree = new XQ.SP.BllServices.SysDegreeBLL();
            //var itemsSysDegree =bllSysDegree.GetModelList();
            //foreach (var mT in  itemsSysDegree)
            //{
            //    ListSysDegreeId.Add(new SelectListItem { Value = mT.Id.ToString(), Text = mT.Name.ToString() });
            //}
            //ViewBag.ListSysDegreeId=ListSysDegreeId;
            //try{
            //model.SysDegreeName=new XQ.SP.BllServices.SysDegreeBLL().GetModel(model.SysDegreeId).Name;
            //}catch { }
            
            #region
            try
            {
            string s="";
            if(model.UserName.Length>80)
            s="用户名字符数不能多于80 !";
            if(model.NO.Length>80)
            s="编号字符数不能多于80 !";
            if(model.Email.Length>160)
            s="邮箱字符数不能多于160 !";
            if(model.IDCard.Length>40)
            s="身份证字符数不能多于40 !";
            if(model.Mobil.Length>30)
            s="手机号码字符数不能多于30 !";
            if(model.RealName.Length>40)
            s="真实名字字符数不能多于40 !";
            if(model.UserPassword.Length>80)
            s="密码字符数不能多于80 !";
            if(model.Telephone.Length>40)
            s="电话号码字符数不能多于40 !";
            if(model.QQ.Length>40)
            s="QQ字符数不能多于40 !";
            if(model.Sex.Length>20)
            s="性别字符数不能多于20 !";
            if(model.Address.Length>200)
            s="地址字符数不能多于200 !";
            if(model.Description.Length>2000)
            s="个性描述字符数不能多于2000 !";
            if(model.PhotoPath.Length>200)
            s="头像(P1字符数不能多于200 !";
            if(model.Degree.Length>200)
            s="等级字符数不能多于200 !";
            if(model.WeiXin.Length>400)
            s="微信字符数不能多于400 !";
            if(model.StuNo.Length>80)
            s="学号字符数不能多于80 !";
            if(model.SelfID.Length>80)
            s="身份证号字符数不能多于80 !";
            if(model.ClassName.Length>80)
            s="名称字符数不能多于80 !";
            if(model.Roles.Length>200)
            s="角色字符数不能多于200 !";
            if(model.DepaName.Length>80)
            s="部门名称字符数不能多于80 !";
            if(model.ImagesBlog.Length>400)
            s="背景图片字符数不能多于400 !";
            if(model.SysDegreeName.Length>80)
            s="等级值字符数不能多于80 !";
            if(!string.IsNullOrEmpty(s))
            {
                ModelState.AddModelError("", s);
                return View(model);
            }
            }catch{}
            #endregion
            
            #region
            #endregion

            model.UpLoginTime = DateTime.Now;
            model.Birthday = DateTime.Now;
            model.CreateTime = DateTime.Now;
            if (model.Id > 0)
            {
                var userCurr = UsersInfo.GetUserH();
                model.Modified = DateTime.Now;
                model.Modifier = userCurr.Id;
                if (bllBase.Update(model))
                    return RedirectToAction("List");
                else
                {
                    ModelState.AddModelError("", "编辑失败");
                }
            }
            else
            {
                var userCurr = UsersInfo.GetUserH();
                model.Creator = userCurr.Id;
                model.Created = DateTime.Now;
                model.Modified = DateTime.Now;
                if (bllBase.Add(model) > 0)
                    return RedirectToAction("List");
                else
                {
                    ModelState.AddModelError("", "添加失败");
                }
            }
            return View(model);
        }
        #endregion

        #region 删除
        [Description("删除")]
        [PermissionFilter]
        public JsonResult Deletes(string ids, long uid)
        {
            if (ids == "1")
            {
                return Json("false", JsonRequestBehavior.AllowGet);
            }
            if (bllBase.DeleteList(ids))
                return Json("true", JsonRequestBehavior.AllowGet);

            return Json("false", JsonRequestBehavior.AllowGet);
        }
        #endregion
        #endregion

        #region 个人中心
        
        #region 个人中心列表
        [Description("个人中心列表")]
        [PermissionFilter]
        public ActionResult MyList(int pageIndex = 1)
        {
            string valueStr = Request.Form["search_input"];
            string search_type = Request.Form["search_type"];
            List<SelectListItem> ListSeach = new List<SelectListItem>();
            ListSeach.Add(new SelectListItem { Value = "username", Text = "用户名" });
            ListSeach.Add(new SelectListItem { Value = "no", Text = "编号" });
            ListSeach.Add(new SelectListItem { Value = "email", Text = "邮箱" });
            ListSeach.Add(new SelectListItem { Value = "idcard", Text = "身份证" });
            ListSeach.Add(new SelectListItem { Value = "mobil", Text = "手机号码" });
            ListSeach.Add(new SelectListItem { Value = "realname", Text = "真实名字" });
            ListSeach.Add(new SelectListItem { Value = "userpassword", Text = "密码" });
            ListSeach.Add(new SelectListItem { Value = "telephone", Text = "电话号码" });
            ListSeach.Add(new SelectListItem { Value = "qq", Text = "QQ" });
            ListSeach.Add(new SelectListItem { Value = "sex", Text = "性别" });
            ListSeach.Add(new SelectListItem { Value = "address", Text = "地址" });
            ListSeach.Add(new SelectListItem { Value = "description", Text = "个性描述" });
            ListSeach.Add(new SelectListItem { Value = "degree", Text = "等级" });
            ListSeach.Add(new SelectListItem { Value = "weixin", Text = "微信" });
            ListSeach.Add(new SelectListItem { Value = "stuno", Text = "学号" });
            ListSeach.Add(new SelectListItem { Value = "classname", Text = "名称" });
            ListSeach.Add(new SelectListItem { Value = "roles", Text = "角色" });
            ListSeach.Add(new SelectListItem { Value = "depaname", Text = "部门名称" });
            ListSeach.Add(new SelectListItem { Value = "imagesblog", Text = "背景图片" });
            ListSeach.Add(new SelectListItem { Value = "sysdegreename", Text = "等级值" });
            ViewBag.ListSeachType = ListSeach;
            @ViewBag.pageIndex=pageIndex;
            @ViewBag.ListSeachValue=valueStr;

            #region
            int pageSize = 20; 
            XQ.Model.Pager.Pager modelP = new XQ.Model.Pager.Pager();
            modelP.tableName = " Users ";
            modelP.fldName = " * ";
            modelP.pageSize = 20;
            modelP.page = pageIndex;
            modelP.fldSort = " Id ";
            modelP.sort = 1;
            modelP.id = " Id ";
            modelP.dist = 1;
            if (!string.IsNullOrEmpty(valueStr))
            {
                modelP.strCondition += " and "+search_type+" like '%" + valueStr + "%' ";
            }
            modelP.strCondition += " and Creator ='" + UsersInfo.GetUsersID() + "' ";
            modelP = DBUtility.DbHelperSQL.GetPage(modelP);
            #endregion
            List<XQ.SP.Model.UsersItem> list = bllBase.DataTableToList(modelP.dt);
            return View(new PagedList<XQ.SP.Model.UsersItem>(list, pageIndex, pageSize, modelP.counts));
        }
        #endregion

        #region 个人中心编辑
        [Description("个人中心编辑")]
        [PermissionFilter]
        public ActionResult MyEdit(long id = 0,int tid=0)
        {
            UsersItem item = new UsersItem();
            item.Status = tid;
            if (id != 0)
            {
                item = bllBase.GetModel(id);
            }

            
            
            List<SelectListItem> ListAttest = new List<SelectListItem>();
            ListAttest.Add(new SelectListItem { Value = "邮箱", Text = "邮箱" });
            ListAttest.Add(new SelectListItem { Value = "手机", Text = "手机" });
            ViewBag.ListAttest=ListAttest;
            List<SelectListItem> ListUserType = new List<SelectListItem>();
            ListUserType.Add(new SelectListItem { Value = "普通用户", Text = "普通用户" });
            ListUserType.Add(new SelectListItem { Value = "代理用户", Text = "代理用户" });
            ViewBag.ListUserType=ListUserType;
            List<SelectListItem> ListSysDegreeId = new List<SelectListItem>();
            XQ.SP.BllServices.SysDegreeBLL bllSysDegree = new XQ.SP.BllServices.SysDegreeBLL();
            foreach (var mT in  bllSysDegree.GetModelList())
            {
                ListSysDegreeId.Add(new SelectListItem { Value = mT.Id.ToString(), Text = mT.Name.ToString() });
            }
            ViewBag.ListSysDegreeId=ListSysDegreeId;
            
            return View(item);
        }

        [Description("个人中心编辑")]
        [PermissionFilter]
        [HttpPost]
        [ValidateInput(false)]
        public ActionResult MyEdit(UsersItem model)
        {
            
            
            
            List<SelectListItem> ListAttest = new List<SelectListItem>();
            ListAttest.Add(new SelectListItem { Value = "邮箱", Text = "邮箱" });
            ListAttest.Add(new SelectListItem { Value = "手机", Text = "手机" });
            ViewBag.ListAttest=ListAttest;
            List<SelectListItem> ListUserType = new List<SelectListItem>();
            ListUserType.Add(new SelectListItem { Value = "普通用户", Text = "普通用户" });
            ListUserType.Add(new SelectListItem { Value = "代理用户", Text = "代理用户" });
            ViewBag.ListUserType=ListUserType;
            List<SelectListItem> ListSysDegreeId = new List<SelectListItem>();
            XQ.SP.BllServices.SysDegreeBLL bllSysDegree = new XQ.SP.BllServices.SysDegreeBLL();
            var itemsSysDegree =bllSysDegree.GetModelList();
            foreach (var mT in  itemsSysDegree)
            {
                ListSysDegreeId.Add(new SelectListItem { Value = mT.Id.ToString(), Text = mT.Name.ToString() });
            }
            ViewBag.ListSysDegreeId=ListSysDegreeId;
            try{
            model.SysDegreeName=new XQ.SP.BllServices.SysDegreeBLL().GetModel(model.SysDegreeId).Name;
            }catch { }
            
            #region
            try
            {
            string s="";
            if(model.UserName.Length>80)
            s="用户名字符数不能多于80 !";
            if(model.NO.Length>80)
            s="编号字符数不能多于80 !";
            if(model.Email.Length>160)
            s="邮箱字符数不能多于160 !";
            if(model.IDCard.Length>40)
            s="身份证字符数不能多于40 !";
            if(model.Mobil.Length>30)
            s="手机号码字符数不能多于30 !";
            if(model.RealName.Length>40)
            s="真实名字字符数不能多于40 !";
            if(model.UserPassword.Length>80)
            s="密码字符数不能多于80 !";
            if(model.Telephone.Length>40)
            s="电话号码字符数不能多于40 !";
            if(model.QQ.Length>40)
            s="QQ字符数不能多于40 !";
            if(model.Sex.Length>20)
            s="性别字符数不能多于20 !";
            if(model.Address.Length>200)
            s="地址字符数不能多于200 !";
            if(model.Description.Length>2000)
            s="个性描述字符数不能多于2000 !";
            if(model.PhotoPath.Length>200)
            s="头像(P1字符数不能多于200 !";
            if(model.Degree.Length>200)
            s="等级字符数不能多于200 !";
            if(model.WeiXin.Length>400)
            s="微信字符数不能多于400 !";
            if(model.StuNo.Length>80)
            s="学号字符数不能多于80 !";
            if(model.SelfID.Length>80)
            s="身份证号字符数不能多于80 !";
            if(model.ClassName.Length>80)
            s="名称字符数不能多于80 !";
            if(model.Roles.Length>200)
            s="角色字符数不能多于200 !";
            if(model.DepaName.Length>80)
            s="部门名称字符数不能多于80 !";
            if(model.ImagesBlog.Length>400)
            s="背景图片字符数不能多于400 !";
            if(model.SysDegreeName.Length>80)
            s="等级值字符数不能多于80 !";
            if(!string.IsNullOrEmpty(s))
            {
                ModelState.AddModelError("", s);
                return View(model);
            }
            }catch{}
            #endregion
            
            #region
            #endregion
            if (model.Id > 0)
            {
                model.Modified = DateTime.Now;
                model.Modifier = UsersInfo.GetUser().Id;
                if (bllBase.Update(model))
                    return RedirectToAction("MyList");
                else
                {
                    ModelState.AddModelError("", "编辑失败");
                }
            }
            else
            {
                model.Creator = UsersInfo.GetUser().Id;
                model.Created = DateTime.Now;
                model.Modified = DateTime.Now;
                if (bllBase.Add(model) > 0)
                    return RedirectToAction("MyList");
                else
                {
                    ModelState.AddModelError("", "添加失败");
                }
            }
            return View(model);
        }
        #endregion

        #region 个人中心删除
        [Description("个人中心删除")]
        [PermissionFilter]
        public ActionResult MyDelete(long id, int pageIndex)
        {
            var item= bllBase.GetModel(id);

            if (bllBase.Delete(id))
                    return RedirectToAction("MyList", new { pageIndex = pageIndex });
                else
                    return RedirectToAction("MyList");
        }
        #endregion
        #endregion

        #region PC端页面
        #region 查询页面
        [Description("查询页面")]
        [PermissionFilter]
        public ActionResult Sele(int pageIndex = 1)
        {
            string valueStr = Request.Form["search_input"];
            string search_type = Request.Form["search_type"];
            List<SelectListItem> ListSeach = new List<SelectListItem>();
            ListSeach.Add(new SelectListItem { Value = "name", Text = "标题" });
            ListSeach.Add(new SelectListItem { Value = "keys", Text = "关键字" });
            ViewBag.ListSeachType = ListSeach;
            @ViewBag.pageIndex = pageIndex;
            @ViewBag.ListSeachValue = valueStr;

            #region
            int pageSize = 20;
            XQ.Model.Pager.Pager modelP = new XQ.Model.Pager.Pager();
            modelP.tableName = " Users ";
            modelP.fldName = " * ";
            modelP.pageSize = 20;
            modelP.page = pageIndex;
            modelP.fldSort = " Id ";
            modelP.sort = 1;
            modelP.id = " Id ";
            modelP.dist = 1;
            if (!string.IsNullOrEmpty(valueStr))
            {
                modelP.strCondition += " and " + search_type + " like '%" + valueStr + "%' ";
            }
            modelP = DBUtility.DbHelperSQL.GetPage(modelP);
            #endregion
            List<XQ.SP.Model.UsersItem> list = bllBase.DataTableToList(modelP.dt);

            return View(new PagedList<XQ.SP.Model.UsersItem>(list, pageIndex, pageSize, modelP.counts));
        }
        #endregion
        #region 详细
        [Description("详细页面")]
        [PermissionFilter]
        public ActionResult D(long id = 1)
        {
            var item = bllBase.GetModel(id);
            return View(item);
        }
        #endregion
        #endregion

        #region APP 小程序 对外接口
        #region 查询接口
        [Description("实体列表接口")]
        [PermissionFilter]
        public JsonResult Selei(int pageIndex = 1,Int64 Id = 0 ,String UserName = "",String NO = "",String Email = "",String IDCard = "",String Mobil = "",String RealName = "",String UserPassword = "",String Telephone = "",String QQ = "",String Sex = "",String Birthday = "",String Address = "",String Description = "",String PhotoPath = "",String CreateTime = "",String UpLoginTime = "",Int32 Integral = 0 ,String Degree = "",Int32 Attest = 0 ,Int32 PostsCount = 0 ,Int32 PostsSaidCount = 0 ,Int32 GoodSaidCount = 0 ,String WeiXin = "",Int32 UsefulCount = 0 ,Int32 UMoney = 0 ,Int32 UserType = 0 ,Int32 Status = 0 ,Int64 Creator = 0 ,String Created = "",Int64 Modifier = 0 ,String Modified = "",String StuNo = "",String SelfID = "",String ClassName = "",Int64 RolesId = 0 ,String Roles = "",Int64 DepaId = 0 ,String DepaName = "",String ImagesBlog = "",Int32 GoodCount = 0 ,Int64 ParentId = 0 ,Int64 SysDegreeId = 0 ,String SysDegreeName = "")
        {
            string valueStr = Request.Form["search_input"];
            string search_type = Request.Form["search_type"];
            List<SelectListItem> ListSeach = new List<SelectListItem>();
            ListSeach.Add(new SelectListItem { Value = "name", Text = "标题" });
            ListSeach.Add(new SelectListItem { Value = "keys", Text = "关键字" });
            ViewBag.ListSeachType = ListSeach;
            @ViewBag.pageIndex = pageIndex;
            @ViewBag.ListSeachValue = valueStr;

            #region
            int pageSize = 20;
            XQ.Model.Pager.Pager modelP = new XQ.Model.Pager.Pager();
            modelP.tableName = " Users ";
            modelP.fldName = " * ";
            modelP.pageSize = pageSize;
            modelP.page = pageIndex;
            modelP.fldSort = " Id ";
            modelP.sort = 1;
            modelP.id = " Id ";
            modelP.dist = 1;
            if (!string.IsNullOrEmpty(valueStr))
            {
                modelP.strCondition += " and " + search_type + " like '%" + valueStr + "%' ";
            }
            
            if (Id!=0)
            {
                modelP.strCondition += " and Id ="+Id+" ";
            }
            if (!string.IsNullOrEmpty(UserName))
            {
                modelP.strCondition += " and UserName like '%"+UserName+"%' ";
            }
            if (!string.IsNullOrEmpty(NO))
            {
                modelP.strCondition += " and NO like '%"+NO+"%' ";
            }
            if (!string.IsNullOrEmpty(Email))
            {
                modelP.strCondition += " and Email like '%"+Email+"%' ";
            }
            if (!string.IsNullOrEmpty(IDCard))
            {
                modelP.strCondition += " and IDCard like '%"+IDCard+"%' ";
            }
            if (!string.IsNullOrEmpty(Mobil))
            {
                modelP.strCondition += " and Mobil like '%"+Mobil+"%' ";
            }
            if (!string.IsNullOrEmpty(RealName))
            {
                modelP.strCondition += " and RealName like '%"+RealName+"%' ";
            }
            if (!string.IsNullOrEmpty(UserPassword))
            {
                modelP.strCondition += " and UserPassword like '%"+UserPassword+"%' ";
            }
            if (!string.IsNullOrEmpty(Telephone))
            {
                modelP.strCondition += " and Telephone like '%"+Telephone+"%' ";
            }
            if (!string.IsNullOrEmpty(QQ))
            {
                modelP.strCondition += " and QQ like '%"+QQ+"%' ";
            }
            if (!string.IsNullOrEmpty(Sex))
            {
                modelP.strCondition += " and Sex like '%"+Sex+"%' ";
            }
            if (!string.IsNullOrEmpty(Birthday))
            {
                modelP.strCondition += " and Birthday like '%"+Birthday+"%' ";
            }
            if (!string.IsNullOrEmpty(Address))
            {
                modelP.strCondition += " and Address like '%"+Address+"%' ";
            }
            if (!string.IsNullOrEmpty(Description))
            {
                modelP.strCondition += " and Description like '%"+Description+"%' ";
            }
            if (!string.IsNullOrEmpty(PhotoPath))
            {
                modelP.strCondition += " and PhotoPath like '%"+PhotoPath+"%' ";
            }
            if (!string.IsNullOrEmpty(CreateTime))
            {
                modelP.strCondition += " and CreateTime like '%"+CreateTime+"%' ";
            }
            if (!string.IsNullOrEmpty(UpLoginTime))
            {
                modelP.strCondition += " and UpLoginTime like '%"+UpLoginTime+"%' ";
            }
            if (Integral!=0)
            {
                modelP.strCondition += " and Integral ="+Integral+" ";
            }
            if (!string.IsNullOrEmpty(Degree))
            {
                modelP.strCondition += " and Degree like '%"+Degree+"%' ";
            }
            if (Attest!=0)
            {
                modelP.strCondition += " and Attest ="+Attest+" ";
            }
            if (PostsCount!=0)
            {
                modelP.strCondition += " and PostsCount ="+PostsCount+" ";
            }
            if (PostsSaidCount!=0)
            {
                modelP.strCondition += " and PostsSaidCount ="+PostsSaidCount+" ";
            }
            if (GoodSaidCount!=0)
            {
                modelP.strCondition += " and GoodSaidCount ="+GoodSaidCount+" ";
            }
            if (!string.IsNullOrEmpty(WeiXin))
            {
                modelP.strCondition += " and WeiXin like '%"+WeiXin+"%' ";
            }
            if (UsefulCount!=0)
            {
                modelP.strCondition += " and UsefulCount ="+UsefulCount+" ";
            }
            if (UMoney!=0)
            {
                modelP.strCondition += " and UMoney ="+UMoney+" ";
            }
            if (UserType!=0)
            {
                modelP.strCondition += " and UserType ="+UserType+" ";
            }
            if (Status!=0)
            {
                modelP.strCondition += " and Status ="+Status+" ";
            }
            if (Creator!=0)
            {
                modelP.strCondition += " and Creator ="+Creator+" ";
            }
            if (!string.IsNullOrEmpty(Created))
            {
                modelP.strCondition += " and Created like '%"+Created+"%' ";
            }
            if (Modifier!=0)
            {
                modelP.strCondition += " and Modifier ="+Modifier+" ";
            }
            if (!string.IsNullOrEmpty(Modified))
            {
                modelP.strCondition += " and Modified like '%"+Modified+"%' ";
            }
            if (!string.IsNullOrEmpty(StuNo))
            {
                modelP.strCondition += " and StuNo like '%"+StuNo+"%' ";
            }
            if (!string.IsNullOrEmpty(SelfID))
            {
                modelP.strCondition += " and SelfID like '%"+SelfID+"%' ";
            }
            if (!string.IsNullOrEmpty(ClassName))
            {
                modelP.strCondition += " and ClassName like '%"+ClassName+"%' ";
            }
            if (RolesId!=0)
            {
                modelP.strCondition += " and RolesId ="+RolesId+" ";
            }
            if (!string.IsNullOrEmpty(Roles))
            {
                modelP.strCondition += " and Roles like '%"+Roles+"%' ";
            }
            if (DepaId!=0)
            {
                modelP.strCondition += " and DepaId ="+DepaId+" ";
            }
            if (!string.IsNullOrEmpty(DepaName))
            {
                modelP.strCondition += " and DepaName like '%"+DepaName+"%' ";
            }
            if (!string.IsNullOrEmpty(ImagesBlog))
            {
                modelP.strCondition += " and ImagesBlog like '%"+ImagesBlog+"%' ";
            }
            if (GoodCount!=0)
            {
                modelP.strCondition += " and GoodCount ="+GoodCount+" ";
            }
            if (ParentId!=0)
            {
                modelP.strCondition += " and ParentId ="+ParentId+" ";
            }
            if (SysDegreeId!=0)
            {
                modelP.strCondition += " and SysDegreeId ="+SysDegreeId+" ";
            }
            if (!string.IsNullOrEmpty(SysDegreeName))
            {
                modelP.strCondition += " and SysDegreeName like '%"+SysDegreeName+"%' ";
            }
            modelP = DBUtility.DbHelperSQL.GetPage(modelP);
            #endregion
            List<XQ.SP.Model.UsersItem> list = bllBase.DataTableToList(modelP.dt);

            return Json(list, JsonRequestBehavior.AllowGet);
            //return View(new PagedList<XQ.SP.Model.UsersItem>(list, pageNo, pageSize, pager.counts));
        }
        #endregion
        #region 单个实体接口
        [Description("单个实体接口")]
        [PermissionFilter]
        public JsonResult Di(long id = 0)
        {
            var item = bllBase.GetModel(id);
            return Json(item, JsonRequestBehavior.AllowGet);
        }
        #endregion
        #endregion
    }
}

